<%@ page pageEncoding="utf-8" contentType="text/html" %>
<%@ page import="model.ChoiceQuestion, java.util.*" %>
<%@ include file='header.tpl.jsp'%>

<%
@SuppressWarnings("unchecked")
Map<Integer, StringBuffer> question_answers = (LinkedHashMap<Integer, StringBuffer>) request.getAttribute("question_answers");
Boolean[] question_result = (Boolean[]) request.getAttribute("question_result[]");
ChoiceQuestion[] qlist = (ChoiceQuestion[]) request.getAttribute("question_list[]");

for(int n = 0; n < qlist.length; n++){
	ChoiceQuestion q = qlist[n];
%>
	<div class="box">
		<h2><%=q.getContent()%></h2>
		<ul class="options">
		<%String[] options = q.getOptions();%>
		<%if(q.getAnswer().length() == 1){%>
			<%for(int i = 0; i < options.length; i++){%>
				<li>
					<label>
						<input type="radio" id="id_<%=q.getQid()%>" name="id_<%=q.getQid()%>" value="<%=i%>" disabled="disabled" <%if(question_answers.get(q.getQid()).toString().contains(Integer.toString(i))){%> checked="checked" <%}%> />
					<%=options[i]%>
					</label>
				</li>
			<%}%>
		<%}else{%>
			<%for(int i = 0; i < options.length; i++){%>
				<li>
					<input type="checkbox" id="id_<%=q.getQid()%>[<%=i%>]" name="id_<%=q.getQid()%>[<%=i%>]" disabled="disabled" <%if(question_answers.get(q.getQid()).toString().contains(Integer.toString(i))){%> checked="checked" <%}%> />
					<label for="id_<%=q.getQid()%>[<%=i%>]"><%=options[i]%></label>
				</li>
			<%}%>
		<%}%>
		</ul>
		<div class="question_result">
		<%if(question_result[n].booleanValue()){%>
			<p>正确</p>
		<%}else{%>
			<p>错误</p>
			<div class="correct_answer">正确答案: <%=q.getAnswer()%></div>
		<%}%>
		</div>
	</div>
<%}%>

<%@ include file='footer.tpl.jsp'%>